# 字符串操作
s1 = 'python'

# 获取长度
print(len(s1))

# 访问字符串中的字符
# 下标访问
print(s1[0], s1[1], s1[-1], s1[-2])

# 切片 访问多个字符
s2 = "WelcomeToChina"
print(s2[3:7])      # come
print(s2[-5:])      # China
print(s2[:7])       # Welcome
# 步长 间隔切
print(s2[0:15:1])   # WelcomeToChina
print(s2[0:15:2])   # Wloeohn
print(s2[0:15:3])   # WceCn

# 拼接
a = 'hello'
b = "world"
print(a+b)                  # helloworld
age = 20
print("this:" + str(age))   # this:20
print(b * 5)                # worldworldworldworldworld
a += b
print(a)                    # helloworld
a = 'user'
a += 'name'
print(a)                    # username
